<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$user_id = get_loggedin_userid();
$id = get_input('id');

if(dt_rate_game($user_id, $id)) {
    $game = dt_get_game($id);
    if ($game) {
        $noun_id = $game->noun_id;
        $adjective_id = $game->adjective_id;
        if($noun_id) {
            dt_update_coins($noun_id, 20);
        }
        if ($adjective_id) {
            dt_update_coins($adjective_id, 20);
        }
    }
    echo json_encode(export_result(200, "1"));
} else {
    echo json_encode(export_result(400, "0"));
}

?>
